// convenience method for jQuery's $(document).ready()
// thanks Tobias Ahlin
// https://tobiasahlin.com/blog/move-from-jquery-to-vanilla-javascript/#document-ready
var ready = (callback) => {
	if (document.readyState != "loading") callback();
	else document.addEventListener("DOMContentLoaded", callback);
}

ready(() => {
	// https://tobiasahlin.com/blog/move-from-jquery-to-vanilla-javascript/#selecting-elements
	document.querySelectorAll('i18n').forEach( element => {
		var msg = element.textContent;
		element.textContent = this.browser.i18n.getMessage(msg);
	});
	
	var languages = ['de', 'en']; // languages supported at this time
	var helplink = $('.help-link').attr('href');
	var privacylink = $('.privacy-link').attr('href');

	if(languages.includes(browser.i18n.getUILanguage())){ // if the user's preferred language is supported by Cloud Firewall all href links will get the respective language code in front of the filetype
	  helplink = 'help.' + browser.i18n.getUILanguage() + '.html';
	  privacylink = 'privacy.' + browser.i18n.getUILanguage() + '.html';
	} else {
	  helplink = 'help.en.html';
	  privacylink = 'privacy.en.html';
	}
});